from django.db import transaction
from django.core.management.base import BaseCommand
from rules.models import Tag

class Command(BaseCommand):
    help = '添加初始标签数据'

    @transaction.atomic
    def handle(self, *args, **kwargs):
        self.stdout.write('开始添加初始标签...')
        
        # 编程语言标签
        language_tags = [
            'Backend', 'Chrome Extension', 'CSS', 'Django', 'Go', 'HTML', 
            'Java', 'JavaScript', 'Jest', 'LLM', 'MagicUl', 'NextJS', 
            'Node.js', 'Novo Elements', 'Pinia', 'Prompt', 'Python', 
            'Radix U', 'Radix Vue', 'React', 'SpringBoot', 'SpringClouad', 
            'SPringMVC', 'Shadcn Ul', 'Shell', 'ShipFast', 'Solidity', 
            'SvelteKit', 'SwiftUl', 'Tailwind', 'Tailwind CSS', 'TypeScript', 
            'Vite', 'Vue', 'Router', 'Wails.io'
        ]
        
        # 使用场景标签
        scenario_tags = [
            'Windows应用程序', '脚本工具', '网站', '游戏', '提示词', '大模型'
        ]
        
        # 添加编程语言标签
        for tag_name in language_tags:
            Tag.objects.get_or_create(
                name=tag_name,
                defaults={'category': 'language'}
            )
            self.stdout.write(f'添加语言标签: {tag_name}')
        
        # 添加使用场景标签
        for tag_name in scenario_tags:
            Tag.objects.get_or_create(
                name=tag_name,
                defaults={'category': 'scenario'}
            )
            self.stdout.write(f'添加场景标签: {tag_name}')
        
        self.stdout.write(self.style.SUCCESS('成功添加所有初始标签!')) 